<?php

class Core_Agent_Component_Profile_View_Profile_Information extends Core_Agent_Share_View_Form {

    protected function buildToolbar($toolbar) {
        $group = $toolbar->createGroup('back');
        $group->addLink($this->getUrl(null,'index','index','index'), $this->__('share.button.back'));
        $group = $toolbar->createGroup('save');
        $group->addButton($this->__('share.button.save'))
        	  ->bindEvent('click', "Kdf.Ui.getForm('".$this->getForm()->getId()."').submit('".$this->getUrl(null, 'updateInformationPost')."')");
        parent::buildToolBar($toolbar);
    }

    protected function buildForm($form) {
        $entity = $this->getModel(NULL);
        $form->setAction($this->getUrl())
                ->setId('content_form')
                ->addHiddenField('id', 'content[id]');
        $form->addTextboxField($this->__('permission.label.real_name'), 'full_name', 'content[full_name]')
                ->addValidateRule('required');
        $form->addTextboxField($this->__('permission.label.QQ'), 'qq', "content[qq]")->addDigitsRule();
        $form->addTextboxField($this->__('permission.label.email'), 'email', 'content[email]')
                ->addValidateRule('email');
        $form->addDatetimeField($this->__('permission.label.birthday'), 'birth', 'content[birth]')->setFormat('Y-m-d');
      	$form->addTextboxField($this->__('permission.label.address'), 'address', 'content[address]');
        $form->addValidateCodeField($this->__('share.label.validate_code'), 'validate_code', 'content[validate_code]')
                ->addValidateRule('required');
        if (!is_null($entity)) {
            $form->bindData($entity->getAllData());
        }
        parent::buildForm($form);
    }

}